package com.badibadi.factory;

import com.badibadi.fragment.AfterLandingMyHomePageFragment;
import com.badibadi.fragment.AfterLandingMyHomePageFriendsApplyForFragment;
import com.badibadi.fragment.AfterLandingMyHomePageOtherPeopleFragment;
import com.badibadi.fragment.AfterLandingMyHomePageMyFriendsFragment;
import com.badibadi.fragment.AfterLandingMyHomePageZhanleiXinFragment;

import android.support.v4.app.Fragment;
import android.util.Log;

public class FragmentFactory {

	/**
	 * 有问题所以没用上
	 * 
	 * @param type
	 * @return
	 * @throws ClassNotFoundException
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public static Fragment getFragment(String type)
			throws ClassNotFoundException, InstantiationException,
			IllegalAccessException {
		Class cl = null;
//		   
		try {
//			   
			cl = Class.forName(type);

		} catch (Exception e) {
			// TODO Auto-generated catch block
			   
		}
//		   
		return (Fragment) cl.newInstance();

	}

	/**
	 * 简单工厂模式 获取fragment的实例
	 * 
	 * @param type
	 * @return
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws Exception
	 */
	public static Fragment getXFragment(String type)
			throws InstantiationException, IllegalAccessException, Exception {
		if (type.equalsIgnoreCase("AfterLandingMyHomePageOtherPeopleFragment"))
			return AfterLandingMyHomePageOtherPeopleFragment.class.newInstance();
		if (type.equalsIgnoreCase("AfterLandingMyHomePageFriendsApplyForFragment"))
			return AfterLandingMyHomePageFriendsApplyForFragment.class
					.newInstance();
		if (type.equalsIgnoreCase("AfterLandingMyHomePageZhanleiXinFragment"))
			return AfterLandingMyHomePageZhanleiXinFragment.class.newInstance();
		if (type.equalsIgnoreCase("AfterLandingMyHomePageMyFriendsFragment"))
			return AfterLandingMyHomePageMyFriendsFragment.class.newInstance();
		if (type.equalsIgnoreCase("AfterLandingMyHomePageFragment"))
			return AfterLandingMyHomePageFragment.class.newInstance();

		// if(type.equalsIgnoreCase("AfterLandingMyHomePageFragment"))
		// return AfterLandingMyHomePageFragment.class.newInstance();
		// if(type.equalsIgnoreCase("AfterLandingMyHomePageFragment"))
		// return AfterLandingMyHomePageFragment.class.newInstance();
		// if(type.equalsIgnoreCase("AfterLandingMyHomePageFragment"))
		// return AfterLandingMyHomePageFragment.class.newInstance();
		// if(type.equalsIgnoreCase("AfterLandingMyHomePageFragment"))
		// return AfterLandingMyHomePageFragment.class.newInstance();
		// if(type.equalsIgnoreCase("AfterLandingMyHomePageFragment"))
		// return AfterLandingMyHomePageFragment.class.newInstance();
		// if(type.equalsIgnoreCase("AfterLandingMyHomePageFragment"))
		// return AfterLandingMyHomePageFragment.class.newInstance();

		return null;

	}
}
